home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15460 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  997 b 

  1. Path: panoramix.fi.upm.es!dia!sacha
  2. From: sacha@diafi.upm.es (Sacha)
  3. Newsgroups: comp.lang.c++
  4. Subject: inheritance of friendship
  5. Date: 5 Apr 1996 16:06:26 GMT
  6. Organization: CS Dept., Technical University of Madrid
  7. Sender: sacha@dia (Sacha)
  8. Distribution: world
  9. Message-ID: <4k3ge2$igu@panoramix.fi.upm.es>
  10. NNTP-Posting-Host: alba.dia.fi.upm.es
  11.  
  12.  
  13. I've just read in the FAQ that friendship isn't inherited: that is if B is a
  14. friend of class A, and class C is derived from B, C ISN'T a friend of A.
  15.  
  16.  
  17.     A     friends with B
  18.                            |
  19.           not friends with C 
  20.  
  21. Is there some way around this?
  22.  
  23. I am overloading << to output to streams, but I don't want to have to rewrite the
  24. same function for each different type of stream. I've tried making both B and C
  25. friends of A and defining the function for B, but this doesn't work.
  26.  
  27. Should I just forget about overloading << and write an outToStream function
  28. instead?
  29.  
  30.  
  31.  
  32. Cheers,
  33.  
  34.  
  35. Sacha.
  36.  
  37. -- 
  38. "It's not just pork, Gilbert, it's power."
  39.